// pages/caicaicai/index.js
let numComper //计算机想的数据
let numUser //用户猜想的数据
Page({
	data: {
		history: []
	},
	onLoad(options) { //生命周期函数--监听页面加载
		numComper = parseInt(Math.random() * 99 + 1)
		console.log("计算机想的数据：" + numComper)
	},
	guessData(e) {
		numUser = parseInt(e.detail.value)
		console.log("用户猜想的数据", numUser)
	},
	caicaicai(e) {
		let history = this.data.history
		history.push(numUser)
		if(history.length>8) history.shift()
		let result = null
		if (numUser > numComper) {
			result = "猜大了~"
		} else if (numUser < numComper) {
			result = "猜小了~"
		} else {
			result = "猜对了~"
		}
		this.setData({
			result: result,
			history,
			userData: null,
			focus: true
		})
	},
})